//
//  MatchDataModel.swift
//  dataBaseProj
//
//  Created by sea on 2020/1/7.
//  Copyright © 2020 CDSCRB. All rights reserved.
//

import UIKit

@objcMembers
class MatchDataModel: NSObject {
    
    var matchDataID:String?

    /// 射门
    var matchDataShoot:String?

    /// 射正
    var matchDataShootIn:String?

    /// 越位
    var matchDataOffside:String? 

    /// 角球
    var matchDataCornnerKick:String?

    /// 犯规
    var matchDataFoul:String?

    /// 黄牌
    var matchDataYellowCard:String?

    /// 红牌
    var matchDataRedCard:String?

    /// 进球
    var matchDataDirveBall:String?

    /// 换人
    var matchDataPlayerChangeTime:String?
    
    //查
    class func getMatchDataModelWithID(matchDataID:String, CompeleteBlock:@escaping compeletBlock){
             let sqlString = "select * from \(matchDataTableName) where \(DHMatchDataID) = \"\(matchDataID)\""
             DHDataBaseManager.shareDataBaseManager.searchWithSql(sql: sqlString) { (result) in
                if (result is FMResultSet){
                     let rs = result as! FMResultSet
                     while rs.next() {
                       let matchdataModel = MatchDataModel()
                       matchdataModel.matchDataID = rs.string(forColumn: DHMatchDataID)
                       matchdataModel.matchDataShoot = rs.string(forColumn: DHMatchDataShoot)
                       matchdataModel.matchDataShootIn = rs.string(forColumn: DHMatchDataShootIn)
                       matchdataModel.matchDataOffside = rs.string(forColumn: DHMatchDataOffside)
                       matchdataModel.matchDataCornnerKick = rs.string(forColumn: DHMatchDataCornnerKick)
                       matchdataModel.matchDataFoul = rs.string(forColumn: DHMatchDataFoul)
                        matchdataModel.matchDataYellowCard = rs.string(forColumn: DHMatchDataYellowCard)
                        matchdataModel.matchDataRedCard = rs.string(forColumn: DHMatchDataRedCard)
                        matchdataModel.matchDataDirveBall = rs.string(forColumn: DHMatchDataDirveBall)
                        matchdataModel.matchDataPlayerChangeTime = rs.string(forColumn: DHMatchDataPlayerChangeTime)
                       CompeleteBlock(matchdataModel)
                     }
                         rs.close()
                 }
             }
         }
    //查

    
   
    class func getMatchDataModelWithID(matchDataID:String)->(MatchDataModel){
        let sqlString = "select * from \(matchDataTableName) where \(DHMatchDataID) = '\(matchDataID)'"
        var model:MatchDataModel?
        DHDataBaseManager.shareDataBaseManager.searchWithSql(sql: sqlString) { (result) in
                       if (result is FMResultSet){
                            let rs = result as! FMResultSet
                            while rs.next() {
                              let matchdataModel = MatchDataModel()
                              matchdataModel.matchDataID = rs.string(forColumn: DHMatchDataID)
                              matchdataModel.matchDataShoot = rs.string(forColumn: DHMatchDataShoot)
                              matchdataModel.matchDataShootIn = rs.string(forColumn: DHMatchDataShootIn)
                              matchdataModel.matchDataOffside = rs.string(forColumn: DHMatchDataOffside)
                              matchdataModel.matchDataCornnerKick = rs.string(forColumn: DHMatchDataCornnerKick)
                              matchdataModel.matchDataFoul = rs.string(forColumn: DHMatchDataFoul)
                               matchdataModel.matchDataYellowCard = rs.string(forColumn: DHMatchDataYellowCard)
                               matchdataModel.matchDataRedCard = rs.string(forColumn: DHMatchDataRedCard)
                               matchdataModel.matchDataDirveBall = rs.string(forColumn: DHMatchDataDirveBall)
                               matchdataModel.matchDataPlayerChangeTime = rs.string(forColumn: DHMatchDataPlayerChangeTime)
                              model = matchdataModel
                            }
                                rs.close()
                        }
    }
      return model!
}

}
